<template>
	<view>
		<view>
			<uni-segmented-control :current="current" :values="items" style-type="text" active-color="#007aff"
				@clickItem="onClickItem" />
		</view>
		<view class="content">
			<view v-if="current === 0">
				<uni-card v-for="item in tableList" :title="'任务名称:' + item.title" :extra="'佣金:' + item.yongjin"
					@click="goGl(item)">
					<text class="uni-body">支付方式:{{item.fangshi}}，时间:{{item.dateTime}}，剩余笔数</text>
				</uni-card>
				<!-- <uni-card title="任务名称" extra="佣金">
					<text class="uni-body">支付方式，时间，剩余笔数</text>
				</uni-card>
				<uni-card title="任务名称" extra="佣金">
					<text class="uni-body">支付方式，时间，剩余笔数</text>
				</uni-card> -->
			</view>
			<view v-if="current === 1">
				<uni-card v-for="item in tableList" :title="'任务名称:' + item.title" :extra="'审核状态:' + item.status"
					@click="goTj(item)">
					<text class="uni-body">支付方式:{{item.fangshi}}，时间:{{item.dateTime}}</text>
				</uni-card>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		baseDefaultUrl
	} from '../../config/config'
	export default {
		created() {
			this.getList(1)
		},
		data() {
			return {
				items: ['我发布的', '我领取的'],
				current: 0,
				tableList: []
			}
		},
		methods: {
			onClickItem(e) {
				if (this.current !== e.currentIndex) {
					this.current = e.currentIndex
					this.getList(this.current + 1)
				}
			},
			shen(uwId, statusw) {
				uni.request({
					url: baseDefaultUrl + "/inter/t-work/shen",
					method: 'GET',
					data: {
						"uwId": uwId,
						"status": statusw
					},
					header: {
						"Authorization": uni.getStorageSync('token')
					},
					success: (res) => {
						if (res.data.code != 0) {
							this.getList(this.current + 1)
						} else {
							alert(res.data.message)
						}
					}
				})
			},
			getList(statusw) {
				uni.request({
					url: baseDefaultUrl + "/inter/t-work/list_work",
					method: 'GET',
					data: {
						"username": uni.getStorageSync("phone"),
						"status": statusw
					},
					header: {
						"Authorization": uni.getStorageSync('token')
					},
					success: (res) => {
						if (res.data.code != 0) {
							this.tableList = res.data.data
						} else {
							alert(res.data.message)
						}
					}
				})
			},
			goTj(params) {
				uni.navigateTo({
					url: '/pages/tijiao/tijiao?id=' + params.id
				})
			},
			goGl(params) {
				uni.navigateTo({
					url: '/pages/gl/gl?id=' + params.id
				})
			},
		}
	}
</script>

<style>

</style>